﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcRags.Examples.Models;
using MvcRags.Filtering;

namespace MvcRags.Examples.Controllers
{
    public class FilteringController : Controller
    {
        ExampleDataContext db = new ExampleDataContext();

        //
        // GET: /Filtering/

        public ActionResult Index()
        {
            FilterMode filterMode = FilterMode.Contains;

            string filterModeString = Request.Params["filterMode"];
            if (!string.IsNullOrWhiteSpace(filterModeString))
                filterMode = (FilterMode)Int32.Parse(filterModeString);
            
            IQueryable<Customer> customers = this.Filter(db.Customers,filterMode);
            ViewBag.SelectedFilterMode = ((int)filterMode).ToString();
            return View(customers);
        }

    }
}
